package com.tyk.bookstore.back.order.model.vo;


import com.tyk.bookstore.back.common.core.model.type.PaymentWay;
import com.tyk.bookstore.back.order.model.enume.CancelReason;
import com.tyk.bookstore.back.order.model.enume.OrderState;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author tyk
 * @description 订单
 */
@Data
public class OrderVo {

    /**
     * OrderDO
     */
    @Schema(description = "ID")
    private Long id;

    @Schema(description = "父订单ID")
    private Long parentId;

    @Schema(description = "订单号")
    private String orderNo;

    @Schema(description = "订单金额")
    private BigDecimal amount;

    @Schema(description = "会员ID")
    private Long memberId;

    @Schema(description = "会员昵称")
    private String memberName;

    @Schema(description = "运费金额")
    private BigDecimal freight;

    @Schema(description = "商品总重量")
    private Long weight;

    @Schema(description = "备注")
    private String note;

    @Schema(description = "订单状态")
    private OrderState state;

    @Schema(description = "仓库ID")
    private Long warehouseId;

    @Schema(description = "运单ID")
    private Long waybillId;

    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

    /**
     * OrderExtraDo
     */
    @Schema(description = "收件人姓名")
    private String cneeName;

    @Schema(description = "收件人电话")
    private String cneePhone;

    @Schema(description = "收件人所在区域")
    private Long cneeAreaCode;

    @Schema(description = "收件人所在区域")
    private String cneeAreaFullName;

    @Schema(description = "收件人地址")
    private String cneeAddress;

    @Schema(description = "支付方式[0商城余额，1支付宝，2微信]")
    private PaymentWay paymentWay;

    @Schema(description = "支付时间")
    private LocalDateTime paymentTime;

    @Schema(description = "订单取消原因")
    private CancelReason cancelReason;

    @Schema(description = "订单取消时间")
    private LocalDateTime cancelTime;

    @Schema(description = "订单详情(当且仅当childList为null)")
    private List<OrderDetail> detailList;

    @Schema(description = "子订单(当且仅当detailList为null)")
    private List<Order> childList;

    @Data
    public static class Order {

        @Schema(description = "ID")
        private Long id;

        @Schema(description = "订单号")
        private String orderNo;

        @Schema(description = "订单金额")
        private BigDecimal amount;

        @Schema(description = "订单状态")
        private OrderState state;

    }

    @Data
    public static class OrderDetail {

        @Schema(description = "书籍ID")
        private Long bookId;

        @Schema(description = "书籍编号")
        private String bookNo;

        @Schema(description = "书籍封面")
        private String cover;

        @Schema(description = "书籍标题")
        private String title;

        @Schema(description = "书籍价格")
        private BigDecimal price;

        @Schema(description = "购买数量")
        private Long num;

    }


}
